package kylin.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * <p>Class:AdminPower</p>
 * <p>Description: 后台权限表</p>
 * @author XQL
 * @Date 2015年9月16日 下午9:43:01
 */
@Entity
@Table(name="adminpower")
public class AdminPower {

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private int id;//序号

	private String name;//权限名称
	
	private String action;//权限地址[action方法]
	
	private int type;//权限类别 0为非菜单 1为菜单
	
	private String clazz;//样式或图片
	
	private String description;//描述
	
	@ManyToOne
	@JoinColumn(name="parentid")
	private AdminPower parent;//父级权限
	
	@Transient
	private List<AdminPower> child = new ArrayList<AdminPower>();
	
	public AdminPower(){}

	public AdminPower(int id) {
		super();
		this.id = id;
	}

	public AdminPower(int id, String name, String action, int type, String clazz, String description, AdminPower parent,
			List<AdminPower> child) {
		super();
		this.id = id;
		this.name = name;
		this.action = action;
		this.type = type;
		this.clazz = clazz;
		this.description = description;
		this.parent = parent;
		this.child = child;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAction() {
		return action;
	}

	public void setAction(String action) {
		this.action = action;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public String getClazz() {
		return clazz;
	}

	public void setClazz(String clazz) {
		this.clazz = clazz;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public AdminPower getParent() {
		return parent;
	}

	public void setParent(AdminPower parent) {
		this.parent = parent;
	}

	public List<AdminPower> getChild() {
		return child;
	}

	public void setChild(List<AdminPower> child) {
		this.child = child;
	}

	@Override
	public String toString() {
		return "AdminPower [id=" + id + ", name=" + name + ", action=" + action + ", type="
				+ type + ", clazz=" + clazz + ", description=" + description + ", parent=" + (parent == null ? null : parent.toString()) + ", child="
				+ (child == null ? null : child.size()) + "]";
	}

}
